<template>
  <a-modal
    :visible.sync="showSalesOrderDetail"
    @cancel="closeSalesOrderDetail"
    title="详情"
    cancelText="关闭"
    :width="modalWidth"
    destroyOnClose
    :confirmLoading="confirmLoading"
    :bodyStyle="tstyle">
    <template slot="footer">
      <a-button key="取消" @click="closeSalesOrderDetail">关闭</a-button>
    </template>

    <a-card :title='"销售订单号："+ soNo' :bordered="true">
      <template>
        <!-- current指定当前步骤，从 0 开始记数 -->
        <a-steps :current='soStatus' labelPlacement="vertical">
          <a-step title="创建"></a-step>
          <a-step title="技术交底"></a-step>
          <a-step title="生产中"></a-step>
          <a-step title="成品校验中"></a-step>
          <a-step title="待发货"></a-step>
          <a-step title="部分发货"></a-step>
          <a-step title="发货完成"></a-step>
          <a-step title="订单完结"></a-step>
        </a-steps>
      </template>
      <a slot="extra">国网推送状态：
        <a-button v-if="dataSourceDetail.ioflag==='0'" type="primary">
          已推送
        </a-button>
      </a>
    </a-card>

    <a-card title="基本信息" style="margin-top: 10px;">
      <a-row :span="24">
        <a-col :span="8">
          采购方总部编码：{{ filterDictText(this.purchaserHqCodeDictOptions, dataSourceDetail.purchaserHqCode) }}
        </a-col>
        <a-col :span="8">
          供应商编码：{{ dataSourceDetail.supplierCode }}
        </a-col>
        <a-col :span="8">
          供应商名称：{{ dataSourceDetail.supplierName }}
        </a-col>
      </a-row>
      <a-row :span="24" style="margin-top: 10px;">
        <a-col :span="8">
          销售订单号：{{ dataSourceDetail.soNo }}
        </a-col>
        <a-col :span="8">
          采购方公司编码：{{ dataSourceDetail.buyerCode }}
        </a-col>
        <a-col :span="8">
          采购方公司名称：{{ dataSourceDetail.buyerName }}
        </a-col>
      </a-row>
      <a-row :span="24" style="margin-top: 10px;">
        <a-col :span="8">
          采购区域：{{ dataSourceDetail.buyerrea }}
        </a-col>
        <a-col :span="8">
          采购方公司省份：{{ dataSourceDetail.buyerProvince }}
        </a-col>
        <a-col :span="8">
          品类编码：{{ filterDictText(this.categoryCodeDictOptions, dataSourceDetail.categoryCode )}}
        </a-col>
      </a-row>
      <a-row :span="24" style="margin-top: 10px;">
        <a-col :span="8">
          种类编码：{{ filterDictText(this.subclassCodeDictOptions, dataSourceDetail.subclassCode) }}
        </a-col>
        <a-col :span="8">
          销售订单状态：{{ dataSourceDetail.soStatus }}
        </a-col>
        <a-col :span="8">
          数据来源：{{ filterDictText(this.dataSourceDictOptions, dataSourceDetail.dataSource) }}
        </a-col>
      </a-row>
      <a-row :span="24" style="margin-top: 10px;">
        <a-col :span="8">
          来源数据创建时间：{{ dataSourceDetail.dataSourceCreateTime }}
        </a-col>
        <a-col :span="8">
          合同编号：{{ dataSourceDetail.conCode }}
        </a-col>
        <a-col :span="8">
          删除标志：{{ filterDictText(this.isDeletedDictOptions, dataSourceDetail.isDeleted) }}
        </a-col>
      </a-row>
      <a-row :span="24" style="margin-top: 10px;">
        <a-col :span="8">
          更新时间：{{ dataSourceDetail.modifyTime }}
        </a-col>
        <a-col :span="8">
          销售订单行项目号：{{ dataSourceDetail.soItemNo }}
        </a-col>
        <a-col :span="8">
          采购订单号：{{ dataSourceDetail.eipPoNo }}
        </a-col>
      </a-row>
      <a-row :span="24" style="margin-top: 10px;">
        <a-col :span="8">
          采购订单行项目ID：{{ dataSourceDetail.poItemId }}
        </a-col>
        <a-col :span="8">
          物资编码：{{ dataSourceDetail.productCode }}
        </a-col>
        <a-col :span="8">
          物资名称：{{ dataSourceDetail.productName }}
        </a-col>
      </a-row>
      <a-row :span="24" style="margin-top: 10px;">
        <a-col :span="8">
          物资单位：{{ dataSourceDetail.productUnit }}
        </a-col>
        <a-col :span="8">
          采购订单厂家计划交货日期：{{ dataSourceDetail.planDeliveryDate }}
        </a-col>
        <a-col :span="8">
          采购订单厂家发货地址：{{ dataSourceDetail.planDeliveryPlace }}
        </a-col>
      </a-row>
      <a-row :span="24" style="margin-top: 10px;">
        <a-col :span="8">
          采购订单厂家发货地址描述：{{ dataSourceDetail.planDeliveryPlaceDesc }}
        </a-col>
        <a-col :span="8">
          物资数量：{{ dataSourceDetail.productAmount }}
        </a-col>
        <a-col :span="8">
          物资ID分组编号：{{ dataSourceDetail.productIdGrpNo }}
        </a-col>
      </a-row>
      <a-row :span="24" style="margin-top: 10px;">
        <a-col :span="8">
          数据拥有方：{{ dataSourceDetail.ownerId }}
        </a-col>
        <a-col :span="8">
          数据可见方：{{ dataSourceDetail.openId }}
        </a-col>
        <a-col :span="8">
          来源数据创建时间：{{dataSourceDetail.dataSourceCreateTime}}
        </a-col>
      </a-row>
      <a-row :span="24" style="margin-top: 10px;">
        <a-col :span="8">
          逻辑删除：{{ filterDictText(this.isDeletedDictOptions, dataSourceDetail.isDeleted) }}
        </a-col>
      </a-row>
    </a-card>

    <a-card title="数据评价详情" style="margin-top: 10px">
      <p>
        <span style="color: blue;">链接审核：</span>
        <span>{{linkMessage}}</span>
      </p>
    </a-card>
  </a-modal>
</template>

<script>
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import SplitPanel from '../../../../jeecg/SplitPanel'
  import { initDictOptions, filterDictText } from '@/components/dict/JDictSelectUtil'

  export default {
    name: 'EipSalesOrderDetail',
    mixins: [JeecgListMixin],
    components: { SplitPanel },
    props: {
      dataSourceDetail: {
        type: Object,
        default: false
      }
    },
    data() {
      //详细信息表头
      return {
        showSalesOrderDetail: true,     //详情页面
        linkMessage: '',
        soNo: '',                       //订单号
        soStatus: 0,                    //订单状态
        purchaserHqCodeDictOptions: [],
        categoryCodeDictOptions: [],
        subclassCodeDictOptions: [],
        dataSourceDictOptions: [],
        isDeletedDictOptions: [],
        modalWidth: '75%',
        tstyle: {
          'height': '700px',
          'overflow': 'auto'
        },
        loading: false,
        confirmLoading: false
      }
    },
    methods: {
      initDictConfig() {
        initDictOptions('purchaserHqCode').then((res) => {
          if (res.success) {
            this.purchaserHqCodeDictOptions = res.result
          }
        })
        initDictOptions('categoryCode').then((res) => {
          if (res.success) {
            this.categoryCodeDictOptions = res.result
          }
        })
        initDictOptions('subclassCode').then((res) => {
          if (res.success) {
            this.subclassCodeDictOptions = res.result
          }
        })
        initDictOptions('dataSource').then((res) => {
          if (res.success) {
            this.dataSourceDictOptions = res.result
          }
        })
        initDictOptions('isDeleted').then((res) => {
          if (res.success) {
            this.isDeletedDictOptions = res.result
          }
        })
      },
      closeSalesOrderDetail() {//详细信息是否关闭
        this.$emit('close')
      },
      handleOk() {
        const that = this
        // 触发表单验证
        this.form.validateFields((err, values) => {
          if (!err) {
            that.confirmLoading = true
            let httpurl = ''
            let method = ''
            if (!this.model.puid) {
              httpurl += this.url.add
              method = 'post'
            } else {
              httpurl += this.url.edit
              method = 'put'
            }
            let formData = Object.assign(this.model, values)
            formData['remark1'] = 'modUser'
            console.log('表单提交数据', formData)
            httpAction(httpurl, formData, method).then((res) => {
              if (res.errorCode === '0') {
                that.$message.success(res.data)
                that.$emit('ok')
              } else {
                that.$message.warning(res.data)
              }
            }).finally(() => {
              that.confirmLoading = false
              that.close()
            })
          }
        })
      },
      loadData() {
        let salesOrder = this.dataSourceDetail
        this.linkMessage = ''
        this.soNo = salesOrder.soNo
        this.linkMessage = salesOrder.remark1 === '10001' ? '【未链接至上一级订单】。' : '【已链接上一级订单】。'
        if (Number(salesOrder.soStatus) === 1) {
          this.soStatus = 0
        }
        if (Number(salesOrder.soStatus) === 3) {
          this.soStatus = 2
        }
        if (Number(salesOrder.soStatus) === 5) {
          this.soStatus = 4
        }
      }
    }
  }
</script>

<style scoped>

</style>